//    Copyright (C) Kherty.  All rights reserved.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;

namespace OpenLS.Spreadsheet.UI
{
    class MoveAdorner : Adorner
    {
        public MoveAdorner(UIElement adornedElement)
            : base(adornedElement)
        {
            Resources.MergedDictionaries.Add(new MoveAdornerResources()); //\\yuck
            Initialize();
        }
        void Initialize()
        {
            _visualChildren = new VisualCollection(this);
            var c = new ContentControl
                        {
                            Template = (ControlTemplate) FindResource("adornerTemplate")
                        };
            _visualChildren.Add(c);
        }
        protected override Size ArrangeOverride(Size finalSize)
        {
            foreach (UIElement e in _visualChildren)
                e.Arrange(new Rect(new Point(0, 0), finalSize));
            return base.ArrangeOverride(finalSize);
        }

        protected override int VisualChildrenCount
        {
            get
            {
                if (_visualChildren == null) return 0;
                return _visualChildren.Count;
            }
        }
        protected override Visual GetVisualChild(int index) { return _visualChildren[index]; }

        VisualCollection _visualChildren;

 

 
 

 



    }
}
